package com.itnoob.demo2;

/**
 * 非终结表达式:添加前缀
 * @author zhoujun
 * @date 2025/3/26 21:48
 */
public class Prefix implements Expression{

    private Expression expression; // 内部表达式

    private String prefix;

    public Prefix(Expression expression, String prefix) {
        this.expression = expression;
        this.prefix = prefix;
    }


    @Override
    public String interpret(String input) {
        //直接返回原始字符
        return   prefix +  expression.interpret(input);
    }
}
